package com.zhao.controller;

import com.zhao.mapper.LoginMapper;
import com.zhao.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@CrossOrigin
public class LoginController {
    @Autowired
    private LoginMapper loginMapper;

    @CrossOrigin
    @PostMapping("/login")
    public Map<String,Object> login(@RequestBody User user){
        Map map=new HashMap();
        User user1 = loginMapper.login(user);
        if(user1==null){
            map.put("code",1001);
            map.put("mag","用户名或密码错误");
        }else{
            map.put("code",1000);
            map.put("id",user1.getId());
            map.put("mag","登录成功");
        }
        return map;
    }
}
